<?php

namespace Trawind\Extension\Models\Deploy;

use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;
use Trawind\Extension\Traits\CustomData;

/**
 * Class BusinessType.
 *
 * @package namespace Trawind\Extension\Models\Deploy;
 */
class BusinessType extends Model implements Transformable
{

    use TransformableTrait, CustomData;

    protected $table = 'deploy_business_types';

    protected $dateFormat = 'U';

    public $incrementing = false;

    protected $connection = 'mysql';

    protected $guarded = ['created_at', 'updated_at'];

    public function queryers()
    {
        return $this->hasMany(BusinessTypeQueryer::class,'business_type_id','id');
    }

    public static function getEloquentByData($data)
    {
        return $data['service'] == config('app.name') ? app($data['local_class']) : app($data['remote_class']);
    }

    public static function getEloquentById(int $businessTypeId)
    {
        return static::getEloquentByData(static::findOrFail($businessTypeId));
    }

}
